# class Solution:
#     def reverse(self, x: int) -> int:
#         if -10 < x < 10:
#             return x
#         strX = str(x)
#         if strX[0] != "-":
#             strX = strX[::-1]
#             x = int(strX)
#         else:
#             strX = strX[:0:-1]
#             x = int(strX)
#             x = -x
#         return x if -2147483648 < x < 2147483647 else 0

# print(int('00001'))

class Solution:
    def reverse(self, x):
        if not x: return x
        if str(x)[0] == '-':
            res = -int(str(x)[:0:-1])
        else:
            res = int(str(x)[::-1].lstrip('0'))
        upper = 2 ** 31 - 1
        lower = - 2 ** 31
        return res if lower < res < upper else 0
int1 = 1534236469
print(Solution().reverse(int1))
'''
整数反转的思路就是转化成为字符串然后判断起始位置的符号是不是-
然后反转的同时需要注意把0 strip掉
然后定义upper和lower，如果超出了范围就是0
upper是2*31-1
lower是-2*31
'''